package com.SpringBoot.mail;

import com.SpringBoot.Util.RedisService;
import com.SpringBoot.Util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("mail")
public class MailController {

    @Autowired
    private MailService mailService;
    @Autowired
    private RedisService redisService;

    @PostMapping("/sendMail")
    public Result sendMail(@RequestParam String email) {
        return mailService.sendMail(email);
    }

    @PostMapping("/verifyCode")
    public Result verifyCode(@RequestParam String email, @RequestParam String code) {
        return mailService.verifyCode(email, code);
    }
}

